import React from 'react';
// 3. 替换掉BrowserRouter，使用Router + history的方式自行绑定Router和history
import { Router, Route, Switch } from 'react-router-dom';
import { AuthRoute } from './components/AuthRoute';
import Login from './pages/Login/index';
import Layout from './pages/Layout';
import history from 'utils/history';

import TestPage from './pages/TestPage';

export default class app extends React.Component {
  render() {
    // BrowserRouter  等价于 Router+ history
    return (
      // 🔔 history作为组件属性设置在Router身上
      <Router history={history}>
        {/* 3. 配置路由规则和组件，使用Switch包住所有的Router */}
        <Switch>
          {/* 4. 设置重定向路由 */}

          <Route path="/login" component={Login}></Route>
          {/* 2. 新建测试路由和测试页面 */}
          <Route path="/test" component={TestPage}></Route>
          <AuthRoute path="/" component={Layout}></AuthRoute>
        </Switch>
      </Router>
    );
  }
}
